package com.wanwu.channel.common.enums;


import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author JiWen
 * @time 2020/3/18 15:26
 */
public enum IdTypeEnum {

    UN_KNOWN(0, "未知"),
    ID(1, "身份证"),
    COMPANY_CODE(2, "公司代码");

    private int code;
    private String desc;

    IdTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static IdTypeEnum getByCode(int code) {
        IdTypeEnum[] values = IdTypeEnum.values();
        for (IdTypeEnum value : values) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }

    public static Map<String, String> toMap() {
        Map<String, String> map = new LinkedHashMap<>();
        for (IdTypeEnum value : values()) {
            map.put(String.valueOf(value.code), value.desc);
        }
        return map;
    }
}
